<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\OperationLogs;
use App\Model\Xtqj;

class XtqjController extends BaseController
{

    protected $model = null;
    /**
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new Xtqj();
    }

    //西天取经游戏列表
    public function getGameList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->getGameList());
    }

    //西天取经游戏配置修改
    public function gameEdit(Request $request){
        $res = $this->model->gameEdit($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经游戏配置修改');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经游戏开启/关闭
    public function gameStatus(Request $request){
        $res = $this->model->gameStatus($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经游戏开启/关闭');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经用户奖池配置列表
    public function getPoolList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->getPoolList($request));
    }

    //西天取经奖池修改
    public function pollEdit(Request $request){
        $res = $this->model->pollEdit($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经奖池修改');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经技能配置列表
    public function skillList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->getSkillList($request));
    }

    //西天取经技能配置新增
    public function skillAdd(Request $request){
        $res = $this->model->skillAdd($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经技能配置新增');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经技能配置修改
    public function skillEdit(Request $request){
        $res = $this->model->skillEdit($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经技能配置修改');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经技能配置删除
    public function skillDelete(Request $request){
        $res = $this->model->skillDelete($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经技能配置删除');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经悬赏配置列表
    public function offerList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->getOfferList($request));
    }

    //西天取经悬赏配置新增
    public function offerAdd(Request $request){
        $res = $this->model->offerAdd($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经悬赏配置新增');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经悬赏配置修改
    public function offerEdit(Request $request){
        $res = $this->model->offerEdit($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经悬赏配置修改');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经悬赏配置删除
    public function offerDelete(Request $request){
        $res = $this->model->offerDelete($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经悬赏配置删除');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经白名单列表
    public function whiteList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->getWhiteList($request));
    }

    //西天取经白名单新增
    public function whiteAdd(Request $request){
        $res = $this->model->whiteAdd($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        // OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经白名单新增');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经白名单修改
    public function whiteEdit(Request $request){
        $res = $this->model->whiteEdit($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        // OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经白名单修改');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经白名单删除
    public function whiteDelete(Request $request){
        $res = $this->model->whiteDelete($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        // OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经白名单删除');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经白名单配置列表
    public function whiteConfigList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->getWhiteConfigList($request));
    }

    //西天取经白名单配置新增
    public function whiteConfigAdd(Request $request){
        $res = $this->model->whiteConfigAdd($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        // OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经白名单配置新增');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经白名单配置删除
    public function whiteConfigDelete(Request $request){
        $res = $this->model->whiteConfigDelete($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        // OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经白名单配置删除');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经白名单用户列表
    public function whiteUserList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->getWhiteUserList($request));
    }

    //西天取经白名单配置新增
    public function whiteUserAdd(Request $request){
        $res = $this->model->whiteUserAdd($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        // OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经白名单用户新增');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经白名单用户删除
    public function whiteUserDelete(Request $request){
        $res = $this->model->whiteUserDelete($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        // OperationLogs::createData($request, OperationLogs::ACTIVITY, '西天取经白名单用户删除');
        return $this->toJson(self::SUCCESS);
    }

    //用户战神榜生成
    public function rankdrawRepair(Request $request){
        $res = $this->model->rankdrawRepair($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '用户战神榜生成');
        return $this->toJson(self::SUCCESS);
    }

    //主播战力榜生成
    public function rankUserRepair(Request $request){
        $res = $this->model->rankUserRepair($request->all());
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        OperationLogs::createData($request, OperationLogs::ACTIVITY, '主播战力榜生成');
        return $this->toJson(self::SUCCESS);
    }

    //西天取经统计数据概述
    public function statSearchAll(Request $request){
        $res = $this->model->statSearchAll($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //西天取经悬赏整体数据统计
    public function statOfferAll(Request $request){
        $res = $this->model->statOfferAll($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //西天取经各悬赏ID数据
    public function statOfferList(Request $request){
        $res = $this->model->statOfferList($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //西天取经各期悬赏数据
    public function statOfferOpenList(Request $request){
        $res = $this->model->statOfferOpenList($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //西天取经悬赏记录各期明细
    public function statOfferFinsihList(Request $request){
        $res = $this->model->statOfferFinsihList($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //西天取经用户参与排行
    public function statUserOrder(Request $request){
        $res = $this->model->statUserOrder($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //西天取经指定用户挑战记录
    public function userDrawList(Request $request){
        $res = $this->model->userDrawList($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //西天取经奖励产出查询
    public function statPoolItem(Request $request){
        $res = $this->model->statPoolItem($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

}
